/*
 * @Description: 
 * @Author: houcw
 * @Date: 2023-11-07 14:56:33
 * @LastEditTime: 2023-11-09 09:47:15
 * @LastEditors: Please set LastEditors
 * @Reference: 
 */
import { fileURLToPath, URL } from 'node:url'

import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router']
    })
  ],
  base: "/endoscopic",

  build: {
    chunkSizeWarningLimit: 1000,
    outDir: "dist",
    // 9月更新
    assetsDir: "assets", //指定静态资源存放路径
    // assetsPublicPath:'',
    sourcemap: false, //是否构建source map 文件
    terserOptions: {
      // 生产环境移除console
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
    rollupOptions: {
      output: {
        // 分包
        manualChunks(id) {
          if (id.includes("node_modules")) {
            return id
              .toString()
              .split("node_modules/")[1]
              .split("/")[0]
              .toString();
          }
        },
      },
    },
  },
  server: {
    https: false, // 是否开启 https
    open: false, // 是否自动在浏览器打开
    port: 8080, // 端口号
    host: "0.0.0.0",
    proxy: {},
    hmr: true,
    // usePolling:true
  },
  define: {
    "process.env": process.env,
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
